import { Controller, Post, Body, UseInterceptors } from '@nestjs/common';
import { IndexInterceptor } from '@libs/common/interceptors';
import { PayloadUser } from '@libs/common/decorator';
import { AccessLogService } from './access-log.service';
import {
  CreateAccessLogDto,
  IndexAccessLogDto,
  ShowAccessLogDto,
  UpdateAccessLogDto,
  DeleteAccessLogDto,
  SwitchAccessLogDto,
  ExportAccessLogDto,
  ImportAccessLogDto,
  FindAccessLogDto,
} from './dto/access-log.dto';

@Controller('access-log')
export class AccessLogController {
  constructor(private readonly accessLogService: AccessLogService) {}

  @Post('index')
  @UseInterceptors(new IndexInterceptor())
  index(@Body() dto: IndexAccessLogDto) {
    return this.accessLogService.index(dto);
  }

  @Post('show')
  show(@Body() dto: ShowAccessLogDto) {
    return this.accessLogService.show(dto);
  }

  @Post('delete')
  delete(@Body() dto: DeleteAccessLogDto) {
    return this.accessLogService.delete(dto);
  }

  @Post('create')
  create(@Body() dto: CreateAccessLogDto) {
    return this.accessLogService.create(dto);
  }

  @Post('update')
  update(
    @Body() dto: UpdateAccessLogDto,
    @PayloadUser() user: SC.User.SysInfo,
  ) {
    // user info
    return this.accessLogService.update(dto);
  }

  // 只返回一条对象数据，如果存在多个只返回第一条
  // @Post('findOne')
  // findOne(@Body() dto: FindAttendanceTodayDto) {
  //   return this.AttendanceTodayService.findOne(dto);
  // }

  // 返回所有符合条件的数据
  // @Post('find')
  // find(@Body() dto: FindAttendanceTodayDto) {
  //   return this.AttendanceTodayService.find(dto);
  // }

  // @Post('import')
  // import(@Body() dto: ExportAccessLogDto) {}

  // @Post('export')
  // export(@Body() dto: ImportAccessLogDto) {}

  // @Post('switch')
  // switch(dto: SwitchAccessLogDto) {
  //   return this.accessLogService.switch(dto.id, dto.status);
  // }
}
